package com.swordxu.yim.android.ui.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;

import com.swordxu.yim.R;
import com.swordxu.yim.android.config.SysConstant;
import com.swordxu.yim.android.imlib.IMSession;
import com.swordxu.yim.android.imlib.utils.IMUIHelper;
import com.swordxu.yim.android.log.Logger;

/**
 * Created by 徐晓明 on 2015/1/13.
 */
public class DetailPortraitActivity extends Activity {

    private Logger logger = Logger.getLogger(DetailPortraitActivity.class);


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tt_activity_detail_portrait);

        Intent intent = getIntent();
        if (intent == null) {
            logger.e("detailPortrait#displayimage#null intent");
            return;
        }

        String resUri = intent.getStringExtra(SysConstant.KEY_AVATAR_URL);
        logger.d("detailPortrait#displayimage#resUri:%s", resUri);

        boolean isContactAvatar = intent.getBooleanExtra(SysConstant.KEY_IS_IMAGE_CONTACT_AVATAR, false);
        logger.d("displayimage#isContactAvatar:%s", isContactAvatar);

        ImageView portraitView = (ImageView) findViewById(R.id.detail_portrait);
        if (portraitView == null) {
            logger.e("detailPortrait#displayimage#portraitView is null");
            return;
        }

        logger.d("detailPortrait#displayimage#going to load the detail portrait");

        if (isContactAvatar) {
            IMUIHelper.setEntityImageViewAvatarNoDefaultPortrait(portraitView, resUri, IMSession.SESSION_P2P);
        } else {
            IMUIHelper.displayImage(portraitView, resUri, -1);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

}
